#读取素材中的“test.txt”文件，使用jieba库进行分词，
#并将出现次数前5的词汇和出现次数信息写入到“output.txt”文件中。
import jieba
with open("text.txt",encoding='utf-8')as file:
    text=file.read();
    words=list(jieba.cue(text));
    word_count={};
    for word in words:
        if word in word_count:
            word_cunt[word]+=1;
        else:
            word_count[word]=1;
    sorted_word_count=sorted(word_count.items(),key=lambda x:x[1],reserse=True);
    with ope('output.txt',"w",encoding='utf-8')as file2:
        for i in range(5);
            file2.write(file2'{sorted_word_count[i][0]}:{sorted_word_count[i][1]}\n');
